//https://leetcode.cn/problems/unique-substrings-in-wraparound-string/submissions/578798981/
class Solution {
public:
    int findSubstringInWraproundString(string s) {
        int n = s.size();
        vector<int> dp(n, 1);
        for (int i = 1; i < n; ++i)
        {
            if (s[i - 1] + 1 == s[i] || s[i] + 25 == s[i - 1])dp[i] += dp[i - 1];
        }
        int arr[26] = { 0 };
        for (int i = 0; i < n; ++i)
        {
            arr[s[i] - 'a'] = max(arr[s[i] - 'a'], dp[i]);
        }
        int sum = 0;
        for (auto tmp : arr)sum += tmp;
        return sum;
    }
};